package com.qnvip.sbd.dao;

import com.qnvip.sbd.mybatis.util.SelectMap;
import com.qnvip.sbd.mybatis.util.UpdateMap;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
public interface Assembler {

	@InsertProvider(type = com.qnvip.sbd.mybatis.sqlprovider.SqlProvider.class, method = "insert")
	@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
	public Integer insert(Object object);

	/**
	 * 无自增长Id的表插入
	 * 
	 * @param object
	 * @return
	 */
	@InsertProvider(type = com.qnvip.sbd.mybatis.sqlprovider.SqlProvider.class, method = "insert")
	public Integer insertNoGeneratedId(Object object);

	@DeleteProvider(type = com.qnvip.sbd.mybatis.sqlprovider.SqlProvider.class, method = "delete")
	public Integer delete(@Param("condition") Object object);

	@UpdateProvider(type = com.qnvip.sbd.mybatis.sqlprovider.SqlProvider.class, method = "updateByUpdateMap")
	public Integer updateByUpdateMap(UpdateMap updateMap);

	@SelectProvider(type = com.qnvip.sbd.mybatis.sqlprovider.SqlProvider.class, method = "count")
	public Integer count(@Param("condition") Object condition, @Param("otherCondition") String otherCondition);

	@SelectProvider(type = com.qnvip.sbd.mybatis.sqlprovider.SqlProvider.class, method = "sum")
	public Double sum(@Param("condition") Object condition, @Param("targetColumn") String targetColumn,
                      @Param("otherCondition") String otherCondition);
	
	@SelectProvider(type = com.qnvip.sbd.mybatis.sqlprovider.SqlProvider.class, method = "selectWithSelectMap")
	public List<Map<String, Object>> select(SelectMap selectMap);

}
